package org.mozhu.mboot.admin.showcase.tree.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Formula;
import org.mozhu.mboot.core.data.entity.BaseTreeable;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 示例-树
 *
 * @author ZhangPei
 */
@Entity
@Table(name = "showcase_tree")
@Data
@EqualsAndHashCode(callSuper = true)
public class Tree extends BaseTreeable {

    /**
     * 是否有叶子节点
     */
    @Formula(value = "(select count(*) from showcase_tree f_t where f_t.parent_id = id)")
    private boolean hasChildren;

}